package com.hectopascal.exception;

import com.hectopascal.exception.Enum.ServiceErrorEnum;
import com.hectopascal.exception.message.ServiceError;

public class ServiceException extends RuntimeException{
    private final transient ServiceError error;

    public ServiceException(String subCode, String subMsg){
        super(subMsg);
        this.error = new ServiceErrorImpl(subCode, subMsg);
    }

    public ServiceException(String subMsg){
        super(subMsg);
        String subCode = "50000";
        this.error = new ServiceErrorImpl(subCode, subMsg);
    }

    public ServiceException(ServiceError error){
        super(error.getSub_msg());
        this.error = error;
    }

    public ServiceError getError(){
        return error;
    }
}
